<template>
  <div class="nav-bar">
<van-nav-bar
  :title="current.title"
  right-text="按钮"
  left-arrow
>
<template #title>
  <div v-if="current.isSearch">
    <van-search shape="round" placeholder="请输入搜索关键字"/>
  </div>
  <div v-else>{{ current.title }}</div>
</template>
</van-nav-bar>
  </div>
</template>
<script>
export default {
}
</script>
<style>
</style>
<script>
export default {
  name: 'NavBar',
  data () {
    return {
      current: {}
    }
  },
  watch: {
    $route: {
      handler (v) {
        // console.log('路由：', v)
        const { title, isSearch } = v.meta
        this.current = {
          title,
          isSearch
        }
      },
      immediate: true
    }
  }
}
</script>
<style lang="less" scoped>
 .van-search{
    padding: 0;
}
</style>
